package acm.蓝桥杯模拟;

import java.util.Scanner;

public class 无聊的前缀和 {

    static int n = 30;
    static int m = 20;
    static int k = 5;

    public static void main(String[] args) {
        int[][] dp = new int[n+k][m+k];
        Scanner sc=new Scanner(System.in);
        int res=0;
        for (int i = k; i < dp.length; i++) {
            for (int j = k; j < dp[0].length; j++) {
                dp[i][j]=sc.nextInt();
//                dp[i][j]+=dp[i-k][j]+dp[i][j-k]-dp[i-k][j-k];
                dp[i][j]+=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
//                res=Math.max(res,dp[i][j]);
            }
        }
        for (int i = k; i < dp.length; i++) {
            for (int j = k; j < dp[0].length; j++) {
                int cur=dp[i][j]-dp[i-k][j]-dp[i][j-k]+dp[i-k][j-k];
                res=Math.max(res,cur);
            }
        }
        System.out.println(res);
    }
}
